home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-12-18 | 1.5 KB | 76 lines | [TEXT/PJMM] |
- {****************************************************}
- {}
- { sTarget.p }
- {}
- { Sprite for the player. Based on the Assignments from the Tutorial. }
- {}
- {****************************************************}
-
-
- unit sTarget;
-
- interface
-
- uses
- SAT, SATTestGlobals;
-
- procedure SetupTarget (me: SpritePtr);
-
- procedure HandleTarget (me: SpritePtr);
-
- procedure HitTarget (me, him: SpritePtr);
-
- implementation
-
- uses
- sPlayer;
-
- const
- kSpeed = 5;
-
- var
- direction: Integer;
-
-
- procedure HandleTarget (me: SpritePtr);
-
- begin { HandleTarget }
- me^.position.h := me^.position.h + direction;
- if me^.position.h <= 0 then
- direction := kSpeed;
- if me^.position.h >= 200 then
- direction := -kSpeed;
- end; { HandleTarget }
-
-
- procedure HitTarget (me, him: SpritePtr);
- var
- savePort: SATPort;
- r: Rect;
- ignore: SpritePtr;
-
- begin { HitTarget }
- if him^.task = @HandlePlayer then {Chack what we hit!}
- begin
- me^.task := nil;
- ignore := SATNewSprite(-1, 0, SATRand(gSAT.offSizeV - 32), @SetupTarget);
- {We could also re-use the old sprite for a new one, if we like.}
- SATSoundPlay(gCatchSound, 1, TRUE);
-
- end;
- end; { HitTarget }
-
-
- procedure SetupTarget (me: SpritePtr);
-
- begin { SetupTarget }
- me^.task := @HandleTarget;
- me^.hitTask := @HitTarget;
- me^.face := SATGetFace(129);
- me^.kind := kindTarget;
- SetRect(me^.hotRect, 0, 0, 32, 32);
- direction := kSpeed;
- end; { SetupTarget }
-
-
- end. { sTarget }